package final2107.night.day09;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Demo01 {
    public static void main(String[] args) {
        int[] ary  = {1,1,1,2,2,2,2,2,7,7,1,5,5,5,0};
        List<Integer> list = new ArrayList<>();
        list.add(ary[0]);
        //对数组从第二位开始进行遍历
        for (int i=1;i<ary.length;i++){
            if (ary[i]!=ary[i-1]){
                list.add(ary[i]);
            }
        }
       //将list转换为数组
        int[] dest = new int[list.size()];
        for (int i=0;i<list.size();i++){
            dest[i]=list.get(i);
        }
        System.out.println(Arrays.toString(dest));
    }
}
